#/bin/bash

BACKUP_DIR='/root/mysql-backup'
# 恢复指定日期，不指定就恢复最新数据
RESTORE_DATE=''

[ "${RESTORE_DATE}" ] && BACKUP_FILE="${RESTORE_DATE}.gz" || BACKUP_FILE="$(ls ${BACKUP_DIR} | sort -r | sed -n 1p)"
gunzip "${BACKUP_DIR}/${BACKUP_FILE}" --stdout | mysql \
-h"node101" \
-u"root" \
-p"123456"
